home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / ptv1n2.arc / 3DWIN.PAS < prev    next >
Pascal/Delphi Source File  |  1990-06-14  |  1KB  |  51 lines

  1. program Box3dExample;
  2.  
  3. uses Graph, Crt;
  4.  
  5. type Style3d = (Concave, Convex);
  6.  
  7. procedure Box3d(Xul,Yul,Xlr,Ylr,Bw,SunC,ShadowC,FillC:integer;
  8. Bs:Style3d);
  9. { Draws a 3d box with top-left corner (Xul, Yul) and bottom-right
  10.   corner (Xlr, Ylr), using a border width of Bw, and a border  
  11. style of Bs (either Concave or Convex), using a sun color of  
  12. Sunc, shadow color ShadowC, and interior fill color FillC. } 
  13.  
  14. var I,T:integer;
  15. begin
  16.   if Bs = Concave then begin { Swap sun and shadow colors }
  17.     T := ShadowC;  ShadowC := SunC;  SunC := T;
  18.   end;
  19.   { For each circuit around the border: }
  20.   for I := 0 to Bw-1 do begin
  21.     SetColor(SunC);
  22.     MoveTo(Xul+I, Ylr-I);     { Draw top/left sides }
  23.     LineTo(Xul+I, Yul+I);
  24.     LineTo(Xlr-I, Yul+I);
  25.     SetColor(ShadowC);
  26.     MoveTo(Xlr-I, Yul+I+1);   { Draw bottom/right sides }
  27.     LineTo(Xlr-I, Ylr-I);
  28.     LineTo(Xul+I+1, Ylr-I);
  29.   end;
  30.   { Fill the interior }
  31.   SetFillStyle(SolidFill,FillC);
  32.   Bar(Xul+Bw, Yul+Bw, Xlr-Bw, Ylr-Bw);
  33. end;
  34.  
  35. var GDriver, Gmode, ErrCode : integer;
  36.     Ch : Char;
  37.  
  38. begin
  39.   Gdriver := Detect;
  40.   InitGraph(GDriver,GMode,'c:\tp55');
  41.   ErrCode := GraphResult;
  42.   if ErrCode <> GrOk then begin
  43.     WriteLn('Graphics error: ',GraphErrorMsg(ErrCode));
  44.     Halt(0);
  45.   end;
  46.   Box3d(5, 5, 100, 100, 3, LightCyan, DarkGray, Cyan, Convex);
  47.   Box3d(42, 42, 62, 62, 3, LightCyan, DarkGray, Cyan, Concave);
  48.   Ch := ReadKey;
  49.   CloseGraph;
  50. end.
  51.